package org.yagnus.scalasupport.iterates

class IterableJavaIterable[T](in: java.lang.Iterable[T]) extends Iterable[T] {
  def iterator: Iterator[T] = return new IteratorJavaIterator(in.iterator);
}
class IteratorJavaIterator[T](in: java.util.Iterator[T]) extends Iterator[T] {
  val itr = in;
  def hasNext = (itr != null && itr.hasNext);
  def next = itr.next;
}

object IterateJavaCollections {
  implicit def iterateOverJavaIterable[T](in: java.lang.Iterable[T]): Iterable[T] = new IterableJavaIterable(in);
  implicit def IterateOverJavaIterator[T](in: java.util.Iterator[T]): Iterator[T] = new IteratorJavaIterator(in);

}